<%@ page contentType="text/html;charset=UTF-8" %>
<spring:eval scope="request" var="forceChangeLoginPassword" expression="@JSPFN.forceChangeLoginPassword()" />
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>${self.title}</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="${self.path.bootstrap}/css/bootstrap.min.css">
    <link rel="stylesheet" href="${self.path.FontAwesome}/css/font-awesome.min.css">
    <link rel="stylesheet" href="${self.path.ionicons}/css/ionicons.min.css">
    ${self.css.plugins}
    <link rel="stylesheet" href="${self.path.app}/css/app.css" />
    ${self.css.main}

    <!--[if lt IE 9]>
      <script src="${self.path.html5shiv}/html5shiv.min.js"></script>
      <script src="${self.path.respond}/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
<c:if test="${not forceChangeLoginPassword}">
    <div>${self.content.main}</div>
</c:if>
    <div id="changeLoginPassword-modal" class="modal fade modal-scroll" tabindex="-1" data-replace="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title"><i class="fa fa-edit"></i> <strong><span id="changeLoginPassword-title">修改登录密码</span>（${loginUser.loginName}）</strong></h4>
          </div>
          <div class="modal-body form">
            <form id="changeLoginPassword-form" method="post" action="${base}/change-login-password" role="form" class="form-horizontal">
              <div class="form-body">
                <div class="form-group">
                  <label class="control-label col-md-3">原登录密码 <span class="required"> * </span></label>
                  <div class="col-md-9">
                    <input type="password" name="plainOldPassword" class="form-control" data-rule-required="1">
                  </div>
                </div>
                <div class="form-group">
                  <label class="control-label col-md-3">新登录密码 <span class="required"> * </span></label>
                  <div class="col-md-9">
                    <input type="password" name="plainNewPassword" id="password" class="form-control" data-rule-required="1">
                  </div>
                </div>
                <div class="form-group">
                  <label class="control-label col-md-3">新密码确认 <span class="required"> * </span></label>
                  <div class="col-md-9">
                    <input type="password" name="plainNewPassword_" class="form-control" data-rule-equalto="#password" data-msg-equalto="两次密码不一致" data-rule-required="1">
                  </div>
                </div>
              </div>
              <div class="form-actions right">
                <button type="submit" id="changeLoginPassword-submit" class="btn btn-success">提交</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
    <script src="${self.path.jquery}/jquery.min.js"></script>
    <script src="${self.path.bootstrap}/js/bootstrap.min.js"></script>
    ${self.js.plugins}
    <script src="${self.path.app}/js/app.js"></script>
<c:if test="${not forceChangeLoginPassword}">
    ${self.js.main}
</c:if>
<c:if test="${forceChangeLoginPassword}">
    <script>
      $(function(){
        var modal = $('#changeLoginPassword-modal');
        modal.find('[data-dismiss="modal"]').hide();
        modal.find('#changeLoginPassword-title').html("请修改登录密码");
        modal.modal({backdrop: 'static', keyboard: false});
        $('#changeLoginPassword-submit').click(function() {
          var form = $('#changeLoginPassword-form');
          $.post(form[0].action, form.serialize(), function(data, textStatus, jqXHR) {
            if (data.resultCode == 'SUCCESS') {
              alert('修改密码成功，请重新登录！');
              window.location = '${base}/logout';
              return;
            }
          	alert(data.errors.join('\n'));
          }, 'json');

          return false;
        });
      });
    </script>
</c:if>
  </body>
</html>
